<div class="container">

    <?php //echo $this->element('page_header'); ?>

    <?php
        if($ticket_found){
    ?>
        <div class="row">
            <div class="span3">
                <?php /*echo $this->element('tickets/navigation'); */?>
                <div id="page-title" class="clearfix">
                    <h1 style="font-size: 16px;"><?php echo 'Ticket No.:  '.$default_data['ticket_id'];?></h1>
                    <ul class="breadcrumb">
                        <li>
                            <span><?php echo 'Subject:'; ?></span>
                            <a href="javascript:void(0);"><?php echo $default_data['subject'];?></a>
                            <span class="divider"></span>
                        </li>
                        <li>
                            <span><?php echo 'Project:'; ?></span>
                            <a href="javascript:void(0);"><?php echo $default_data['project'];?></a>
                            <span class="divider"></span>
                        </li>
                        <li>
                            <span><?php echo 'Priority:'; ?></span>
                            <a href="javascript:void(0);"><?php echo $default_data['priority'];?></a>
                            <span class="divider"></span>
                        </li>
                        <li>
                            <span><?php echo 'Due Date:'; ?></span>
                            <a href="javascript:void(0);"><?php echo $default_data['due_dt'];?></a>
                            <span class="divider"></span>
                        </li>
                        <li>
                            <span><?php echo 'Estimated Hrs:'; ?></span>
                            <a href="javascript:void(0);"><?php echo $default_data['estimated_hrs'];?></a>
                            <span class="divider"></span>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="span9">

                <div class="widget">

                    <div class="widget-header">
                        <h3>
                            <i class="icon-th-list"></i>
                            Update Ticket Form
                        </h3>
                    </div> <!-- /widget-header -->

                    <div class="widget-content" style="padding-top: 0px;">
                        <?php
                        $error = false;
                        if($this->Session->check('process_error')){
                            if($this->Session->read('process_error') == 'yes'){
                                $error = true;
                            }
                            $controller->Session->delete('process_error');
                        }
                        ?>
                        <?php
                        $flash_msg = $this->Session->read('Message');
                        if(isset($flash_msg['flash'])){
                            ?>
                            <div class="row-fluid">
                                <div class="span12">
                                    <?php
                                    if($error){
                                        echo $this->Message->msg('Status',$this->Session->flash(),'error',true);
                                    }
                                    else{
                                        echo $this->Message->msg('Status',$this->Session->flash(),'success',true);
                                    }
                                    ?>
                                </div>
                            </div>
                        <?php
                        }
                        ?>
                        <?php echo $this->Form->create('Ticket', array('type' => 'file','id' => 'form','class'=>'form-horizontal'));?>
                        <fieldset>
                            <legend>Details</legend>
                            <div class="control-group">
                                <div class="control-inner-group">
                                    <label class="control-label" for="user_id">Assign To</label>
                                    <div class="controls">
                                        <?php
                                            if($authUser['type'] == 'Staff'){
                                            ?>
                                                <div class="input-append">
                                                    <span class="add-on"><?php echo $assign_to[$default_data['assign_to']]; ?></span>
                                                </div>
                                            <?php
                                                echo $this->Form->input('user_id', array('type' => 'hidden','id' => 'user_id', 'value'=>$default_data['assign_to'], 'div' => false, 'label' => false));
                                            }
                                            else{
                                                echo $this->Form->input('user_id', array('id' => 'user_id', 'required' => 'required', 'options' => $assign_to, 'value'=>$default_data['assign_to'],'class' => 'span3', 'div' => false, 'label' => false));
                                            }
                                        ?>
                                    </div>
                                </div>
                                <div class="control-inner-group">
                                    <label class="control-label" for="status_id">Status</label>
                                    <div class="controls">
                                        <?php echo $this->Form->input('status_id', array('id' => 'status_id', 'required' => 'required', 'options' => $status, 'value'=>$default_data['status_id'],'class' => 'span2', 'div' => false, 'label' => false)); ?>
                                    </div>
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="comments">Comments</label>
                                <div class="controls">
                                    <?php echo $this->Form->input('comments', array('type'=>'textarea','id' => 'comments', 'required' => 'required', 'value'=>$default_data['comments'], 'class' => 'span6', 'div' => false, 'label' => false)); ?>
                                </div>
                            </div>
                            <div class="control-group">
                                <?php
                                if($authUser['type'] == 'Staff'){

                                }
                                else{
                                    ?>
                                    <label class="control-label" for="notify_list">Notify List</label>
                                    <span id="dualselect" class="dualselect">
                                        <select name="data[Ticket][notify_list][]" id="notify_list" multiple="multiple" size="10">
                                            <?php
                                                foreach( $assign_to as $key=>$value){
                                            ?>
                                                    <option value="<?php echo $key; ?>"><?php echo $value; ?></option>
                                            <?php
                                                }
                                            ?>
                                        </select>
                                            <?php /*echo $this->Form->input('notify_list', array('type'=>'select' ,'id' => 'notify_list','multiple'=>'multiple', 'size'=>'10', 'div' => false, 'label' => false)); */?>

                                            <span class="ds_arrow">
                                            <button class="btn ds_prev"><i class="icon-arrow-left"></i></button><br /><br />
                                            <button class="btn ds_next"><i class="icon-arrow-right"></i></button>
                                        </span>
                                            <?php echo $this->Form->input('user_list', array('id' => 'user_list', 'options' => $other_assign_to, 'class' => 'uniformselect','multiple'=>'multiple', 'size'=>'10', 'div' => false, 'label' => false)); ?>
                                    </span>
                                    <?php
                                }
                                ?>
                                <?php echo $this->Form->input('id', array('type'=>'hidden', 'value'=>$default_data['ticket_id'], 'div' => false, 'label' => false)); ?>
                                <?php echo $this->Form->input('modified_by', array('type'=>'hidden', 'value'=>$default_data['modified_by'], 'div' => false, 'label' => false)); ?>
                            </div>
                        </fieldset>

                        <fieldset>
                            <legend>Project Management</legend>
                            <?php
                            if($authUser['type'] == 'Staff'){

                            }
                            else{
                                ?>
                                <div class="control-group">
                                    <div class="control-inner-group">
                                        <label class="control-label" for="completion_dt">Estimated Completion Date</label>
                                        <div class="controls">
                                            <?php echo $this->Form->input('completion_dt', array('type'=>'text','id' => 'completion_dt', 'class' => 'span3','required' => 'required', 'placeholder' => 'YYYY-MM-DD', 'div' => false, 'label' => false));?>
                                        </div>
                                    </div>

                                    <div class="control-inner-group">
                                        <label class="control-label" for="actual_hrs">Actual Hours</label>
                                        <div class="controls">
                                            <div class="input-append">
                                                <?php echo $this->Form->input('actual_hrs', array('type'=>'text','id' => 'actual_hrs', 'class' => 'span2' ,'value' => '', 'div' => false, 'label' => false)); ?>
                                                <span class="add-on">hr(s)</span>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label" for="due_dt">Percentage Complete</label>
                                    <div class="controls">
                                        <div class="input-append">
                                            <?php echo $this->Form->input('percentage_complete', array('type' => 'text','id' => 'percentage_complete','class' => 'span3', 'div' => false, 'label' => false)); ?>
                                            <span class="add-on">%</span>
                                        </div>
                                    </div>
                                </div>
                            <?php
                            }
                            ?>



                        </fieldset>

                        <fieldset>
                            <legend>Attachments</legend>
                            <div class="control-group">
                                <label class="control-label" for="due_dt">Add Attachments</label>
                                <div class="controls">
                                    <?php echo $this->Form->input('attach', array('type' => 'file','id' => 'attach', 'div' => false, 'label' => false)); ?>
                                </div>
                            </div>
                        </fieldset>

                        <fieldset>
                            <div class="form-actions">
                                <button type="submit" class="btn btn-primary btn-large">Update Ticket</button>
                                <button type="reset" class="btn btn-large">Cancel</button>
                            </div>
                        </fieldset>
                        <?php echo $this->Form->end();?>
                    </div> <!-- /widget-content -->

                </div> <!-- /widget -->

                <div class="row">
                    <div class="span9">
                        <?php echo $this->element('tickets/ticket_trail'); ?>
                    </div>
                </div>

            </div>

        </div> <!-- /.row -->
    <?php
        }
        else{
    ?>
        <div class="row">
            <div class="span12">
                <?php
                echo $this->Message->msg('Ticket Status','There was no ticket found!','error');
                ?>
            </div>
        </div>
    <?php
        }
    ?>
</div> <!-- /.container -->

<?php
    echo $this->Html->script('Scripts/ticket_update.js');
?>